]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensionSystem: Include dir and path in data passed to extension
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 16 Jul 2023 12:40:08 +0000 (14:40 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sat, 29 Jul 2023 12:20:20 +0000 (15:20 +0300)
Extensions often need to set up additional resources from their
directory, like settings, translations or image assets.

So far extensions have used getCurrentExtension() to access the
shell's internal extension object which contains path and dir
properties. That's far from ideal, first because it requires
generating a stack to figure out the current extension, and
second because the internal object also contains state that
extensions shouldn't meddle with.

Just include those properties in the metadata we pass to the
extension constructor.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2838>

js/ui/extensionSystem.js

index abe98b574b72e42492424396e075182b0713d29b..d2f608f4c18fa1fefc78c295d2eb0421e5aeeec4 100644 (file)
@@ -536,7 +536,9 @@ var ExtensionManager = class extends Signals.EventEmitter {
         }
 
         try {
-            extensionState = new extensionModule.default(extension.metadata);
+            const {metadata, path} = extension;
+            extensionState =
+                new extensionModule.default({...metadata, dir, path});
         } catch (e) {
             this.logExtensionError(uuid, e);
             return false;